package com.atguigu.controller;


import com.atguigu.entity.AlbumInfo;
import com.atguigu.entity.BaseCategory1;
import com.atguigu.minio.MinIoUploader;
import com.atguigu.result.RetVal;
import com.atguigu.service.AlbumInfoService;
import com.atguigu.service.BaseCategory1Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.redisson.api.RBloomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 一级分类表 前端控制器
 * </p>
 *
 * @author Joe
 * @since 2024-11-15
 */
@Tag(name = "并发管理")
@RestController
@RequestMapping("/api/album")
public class ConcurentController {

    @Autowired
    private BaseCategory1Service category1Service;

    @Autowired
    private AlbumInfoService albumInfoService;

    @Autowired
    private RBloomFilter bloomFilter;
    @Operation(summary = "sample")
    @GetMapping("/setNum")
    public String setNum()  {
        category1Service.setNum();
        return "sucess";
    }
    @Operation(summary = "初始化布隆过滤器")
    @GetMapping("init")
    public String init()  {
        //查询数据库里面的专辑id
        LambdaQueryWrapper<AlbumInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(AlbumInfo::getId);
        List<AlbumInfo> albumInfoList = albumInfoService.list(wrapper);
        albumInfoList.forEach(albumInfo -> {
                    Long albumInfoId = albumInfo.getId();
                    //把id放到布隆过滤器里面
                    bloomFilter.add(albumInfoId);
                });
        return "sucess";
    }
}
